<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="demo"></div>
    <script src="../index.browser.js"></script>
    <script> 
      const demo = document.getElementById("demo"); 

      const options = [
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "t",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "b",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "l",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "r",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "tl",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "tr",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "bl",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.6)",
            angle: 0,
            position: "br",
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.2)",
            angle: 0,
            position: [-50, 0],
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.2)",
            angle: 0,
            position: [0, 0],
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.2)",
            angle: 45,
            position: [0, 0],
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 30,
            color: "rgba(250, 100, 20, 0.2)",
            angle: -45,
            position: [0, 0],
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.2)",
            angle: 0,
            repeat: 100,
            lineHeight: -50,
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: "rgba(255, 255, 255, 0.2)",
            angle: 45,
            repeat: 100,
            lineHeight: -60,
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 30,
            color: "rgba(100, 0, 250, 0.5)",
            angle: -45,
            repeat: 150,
            lineHeight: -120,
          },
        },
        {
          text: "水印文字",
          option: {
            fontSize: 20,
            color: () => `rgba(255, 255, 255, ${Math.random()})`,
            angle: 45,
            repeat: 100,
            lineHeight: -60,
          },
        },
      ];
      (async () => {
        // let cav=await imageToCanvas("https://browser6.qhimg.com/dmfd/290_164_/t0111d2fa06185f6764.jpg")
        // cav.style.marginRight = "10px";
        // demo.appendChild(cav);
        for (let i of options) {
          const img = document.createElement("img");
          // 示例
          img.src = await addWatermark("https://browser6.qhimg.com/dmfd/290_164_/t0111d2fa06185f6764.jpg", i.text, i.option);
          // img.src = await addWatermark("https://picsum.photos/200/300", i.text, i.option);
          img.style.marginRight = "10px";
          demo.appendChild(img);
        }
      })();
    </script>
  </body>
</html>
